<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Popup Test</title>
</head>
<body>
    <a href="https://github.com/CefSharp/CefSharp" target="_blank">target=_blank</a>
    <br />
    <a href="#" onclick="window.open('https://github.com/CefSharp/CefSharp')">window.open()</a>
    <br />
    <a href="#" onclick="window.open('custom://cefsharp/BindingTest.html')">BindingTest.html</a>
    <br />
    <a href="#" onclick="window.open('custom://cefsharp/MultiBindingTest.html')">MultiBindingTest.html</a>
    <br />
    <button id="openMyWindow">Open "myWindow"</button>
    <button id="closeMyWindow">Close "myWindow"</button>

    <script>
        var myWindow;

        document.getElementById('openMyWindow').addEventListener('click', function (e)
        {
            myWindow = window.open('/HelloWorld.html', 'Popup WindowName', "menubar=0,resizable=1,location=0,status=0,scrollbars=1,width=640,height=480");

            try
            {
                myWindow.darkTheme = false;

                myWindow.addEventListener('DOMContentLoaded', (event) =>
                {
                    myWindow.document.write("<title>Foo Title</title>");
                    myWindow.document.write("<body>This is the new body</body>");
                    myWindow.document.close();

                    //myWindow.document.title = "Foo Title";
                    //myWindow.document.body.innerHTML += "<br/>Appended to document body";

                    console.log('Popup body and title updated:', myWindow.document.body.outerHTML);
                });                
            }
            catch (e)
            {
                console.log('popup error', e);
            }
        });

        document.getElementById('closeMyWindow').addEventListener('click', function (e)
        {
            myWindow.close();
        });
    </script>
</body>
</html>
